<link rel="stylesheet" href="/upload/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="/upload/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="/upload/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="/upload/kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="/upload/kindeditor/plugins/code/prettify.js"></script>
<script type="text/javascript" src="<?php echo $this->module->assetsUrl; ?>/datepicker/WdatePicker.js" /></script>

<script charset="utf-8" src="<?php echo $this->module->assetsUrl; ?>/js/jquery.Jcrop.js"></script>
<link rel="stylesheet" href="<?php echo $this->module->assetsUrl; ?>/css/jquery.Jcrop.css" />



<script >


    KindEditor.ready(function(K) {
                
            editor = K.create('#ActivityLinkSignup_content', {
            allowPreviewEmoticons: false,
            allowImageUpload: true,
            allowFileManager: true,
           // fileManagerJson : 'kindeditor/php/file_manager_json.jsp',
           
            resizeType : 1,
            items : [
           'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about']
          
                });

            });
            
</script>




<script >
var url_host = "http://<?php echo Yii::app()->params['HTTP_HOST']; ?>";

function uploadImag(Nid,thumb){
             
             KindEditor.ready(function(K) {
        var editor = K.editor({
            allowPreviewEmoticons: false,
            allowImageUpload: true,
            allowFileManager: true,
            urlType: 'domain'
           // uploadJson : '/uploadImg'
             
        });

            editor.loadPlugin('image', function() {
                editor.plugin.imageDialog({
                    
                    fileUrl: K('#'+Nid).val(),
                    clickFn: function(url, title) {
                        // var file_url_img = "http://m.kxiche.com";
                        //var file_url_img = "http://localhost:8087";
                       // if (url.indexOf("http") > -1) {
                            K('#'+Nid).val(url_host + url);
                            K('#'+thumb).attr('src', url_host + url);
                          
                           // K('.jcrop-tracker img').attr('src', url_host + url);
                            K('#jiancai_a_url').attr('src',url_host + url);
                            K('#input_img_url_url').val(url_host + url);
                            K('#'+Nid).attr('type', 'text');
                            
                             if(!K('#btn_cut').text()){
                                    K('#'+thumb).after('<button  id="btn_cut" type="button" data-toggle="modal" data-target="#myModal_crop_url" >裁剪</button>');
                             }
                            K('#img_type').val(thumb);
                            editor.hideDialog();
							//$('#myModal_crop_url').modal('show');
                            jiancai_url(thumb);//jcrop初始化
                    }
                });
            });
      });
            
  }

</script>




<style type="text/css">

    div.form label.labelForRadio 
    {
        display:inline-block;
        width:auto;float:none;
    }


</style>



<div class="container-fluid">

    <div class="row-fluid">
        <div class="span12">
            <h3 class="page-title">
                活动管理 <small>添加</small>
            </h3>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a href="index.html">活动管理</a> 
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">添加</a></li>

            </ul>
            <!-- END PAGE TITLE & BREADCRUMB-->
        </div>
    </div>

    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN SAMPLE FORM PORTLET-->  

            <div class="alert alert-info">  
                <?php echo Yii::app()->user->getFlash('addform'); ?>  
            </div> 
            <div class="portlet box blue tabbable">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="icon-reorder"></i>
                        <span class="hidden-480">活动选择</span>
                    </div>
                </div>
                <div class="portlet-body form">
                    <div class="tabbable portlet-tabs">
                        <ul class="nav nav-tabs">

                            <?php
                            switch ($Activity->type_id)
                            {

                                case '101':
                                    echo '<li class="active"><a href="#portlet_tab1" data-toggle="tab">报名活动</a></li>';
                                    break;
                                case '102':
                                    echo '<li ><a href="#portlet_tab2" data-toggle="tab">投票活动</a></li>';
                                    break;

                                default:
                                    echo '<li class="active"><a href="#portlet_tab1" data-toggle="tab">报名活动</a></li><li ><a href="#portlet_tab2" data-toggle="tab">投票活动</a></li>';
                                    break;
                            }
                            ?>

                        </ul>
                        
                        <div class="tab-content">
                            <div class="tab-pane active"  id="portlet_tab1">
                                <!-- BEGIN FORM-->
                                <?php
                                $form = $this->beginWidget(
                                        'CActiveForm', array(
                                    'id' => 'active-form',
                                    // 'enableAjaxValidation'=>true,   
                                    'enableClientValidation' => true,
                                    'clientOptions' => array(
                                        'validateOnSubmit' => true,
                                    ),
                                    'htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal'),
                                        // 'action'=>array('/admin'),
                                ));
                                ?>
                                <?php if(!Yii::app()->user->Alumni_id):?>
                                    <div class="control-group">
                                            <label class="control-label">地区学院</label>
                                            <div class="controls">
                                                <?php echo  CHtml::dropDownList('Activity[alumni_id]','',CHtml::listData(Alumni::model()->findAllByAttributes(array('status'=>1,'is_del'=>2,'parent_id'=>0)),'id', 'rename'));?>
                                            </div>
                                   </div>
  
                                    <?php elseif(!Yii::app()->user->parent_id):?>    
                                     
                                    <div class="control-group">
                                            <label class="control-label">地区学院</label>
                                            <div class="controls">
                                                <?php echo  CHtml::dropDownList('Activity[alumni_id]','',CHtml::listData(Alumni::model()->findAll(
                                                        "parent_id=:parent_id and status=:status and is_del=:is_del or "
                                                        . "id=:id and status=:status and is_del=:is_del",
                                                        array(
                                                                'parent_id'=>Yii::app()->user->Alumni_id,
                                                                 'id'=>Yii::app()->user->Alumni_id,
                                                                 'is_del'=>2,
                                                                 'status'=>1 
                                                            )
                                                    ),'id','rename'));?>
                                            </div>
                                    </div>
                                <?php else:?>       
                                 <input type="hidden" id="Activity_alumni_id" name="Activity[alumni_id]" value="<?php echo Yii::app()->user->Alumni_id; ?>">
                                <?php endif;?>

                                <div class="control-group">
                                     <label class="control-label">是否热点</label>
                                     <div class="controls">
                                         <?php
                                         echo $form->radioButtonList($Activity, 'is_hot', array(1 => '是', 2 => '否'), array(
                                             'separator' => '&nbsp&nbsp&nbsp&nbsp&nbsp',
                                             'labelOptions' => array('class' => 'labelForRadio'),
                                             'style' => 'margin-left:0',
                                         ));
                                         ?>
                                     </div>
                                 </div>
                                
                                
                                <div class="control-group">
                                    <label class="control-label">活动类型</label>
                                    <div class="controls">
                                          <?php echo $form->dropDownList($Activity,'cat_id',Type::model()->getCategoryList(), array(
                                                                    'empty' => '请选择',
                                                                    'style' => 'width:95px',
                                                                        )); ?>
                                           <?php echo $form->error($Activity,'cat_id',array('class' => 'label label-danger')); ?>
                                    </div>
                                </div>
                               <input type="hidden" id="Activity_type_id" name="Activity[type_id]" value="101" class="m-wrap small" />

                                
                              
                                <div class="control-group">
                                    <label class="control-label">标题</label>
                                    <div class="controls">

                                        <?php echo $form->textField($Activity, 'title', array('class' => 'm-wrap large', 'placeholder' => "标题")) ?>
                                        <?php echo $form->error($Activity, 'title', array('class' => 'label label-danger')); ?>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">活动时间</label>
                                    <div class="controls">

                                        <?php echo $form->textField($Activity, 'start_time', array('class' => 'm-wrap medium', 'placeholder' => "开始时间", 'onclick' => "WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});")) ?>
                                        <?php echo $form->textField($Activity, 'end_time', array('class' => 'm-wrap medium', 'placeholder' => "结束时间", 'onclick' => "WdatePickerSet($('#Activity_start_time').val())")) ?>
                                        <?php echo $form->error($Activity, 'start_time', array('class' => 'label label-danger')); ?>
                                        <?php echo $form->error($Activity, 'end_time', array('class' => 'label label-danger')); ?> 
                                    </div>
                                </div>

                                <div class="control-group" >
                                    <label class="control-label">活动背景图片</label>
                                    <div class="controls">
                                        <div class="fileupload fileupload-new" data-provides="fileupload">
                                            <img id="file_upload_ws" src="" width="150" height="85" />
                                            <input type="hidden" name='Activity[banner_url]' id="Activety_banner_url">
                                            <input type="button"  id="Activity-btn-upload"  onclick="uploadImag('Activety_banner_url','file_upload_ws')" value='点击上传' />      
											<span> 请上传尺寸为700*450的图!</span>
										</div> 
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">活动背景缩略图片</label>
                                    <div class="controls">
                                        <div class="fileupload fileupload-new" data-provides="fileupload">
                                            <img id="file_upload_ws_min" src="" width="50" height="50" />
                                            <input type="hidden" name='Activity[min_banner_url]' id="Activety_min_banner_url">
                                            <input type="button" onclick="uploadImag('Activety_min_banner_url','file_upload_ws_min')" value='点击上传' />      
											<span> 请上传尺寸为100*100的图!</span>
                                        </div> 
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">是否签到</label>
                                    <div class="controls">
                                        <?php
                                        echo $form->radioButtonList($ActivityLinkSignup, 'is_need_checkin', array(1 => '是', 2 => '否'), array(
                                            'separator' => '&nbsp&nbsp&nbsp&nbsp&nbsp',
                                            'labelOptions' => array('class' => 'labelForRadio'),
                                            'style' => 'margin-left:0',
                                        ));
                                        ?>
                                    </div>
                                </div>
                               
                                <div class="control-group" id="checkintime" style="display:none;" >
                                    <label class="control-label">签到时间</label>
                                    <div class="controls">
                                        <input type="text"  id="ActivityLinkSignup_checkin_start_time" value="<?php echo $ActivityLinkSignup->checkin_start_time ?>" placeholder="开始时间" name="ActivityLinkSignup[checkin_start_time]" class="m-wrap medium" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});" />
                                        <input type="text" id="ActivityLinkSignup_checkin_end_time" value="<?php echo $ActivityLinkSignup->checkin_end_time ?>" placeholder="结束时间" name="ActivityLinkSignup[checkin_end_time]" class="m-wrap medium" onclick="WdatePickerSet($('#ActivityLinkSignup_lottery_start_time').val())" />

                                    </div>
                                </div>


                                <div class="control-group">
                                    <label class="control-label">是否抽奖</label>
                                    <div class="controls">
                                        <?php
                                        echo $form->radioButtonList($ActivityLinkSignup, 'is_need_lottery', array(1 => '是', 2 => '否'), array(
                                            'separator' => '&nbsp&nbsp&nbsp&nbsp&nbsp',
                                            'labelOptions' => array('class' => 'labelForRadio'),
                                            'style' => 'margin-left:0',
                                        ));
                                        ?>

                                    </div>
                                </div>

                                

                                <div class="control-group">
                                    <label class="control-label">是否报名</label>
                                    <div class="controls">
                                        <?php
                                        echo $form->radioButtonList($ActivityLinkSignup, 'is_need_signup', array(1 => '是', 2 => '否'), array(
                                            'separator' => '&nbsp&nbsp&nbsp&nbsp&nbsp',
                                            'labelOptions' => array('class' => 'labelForRadio'),
                                            'style' => 'margin-left:0',
                                        ));
                                        ?>
                                    </div>
                                </div>



                                <div class="control-group" id="signuptime" style="display:none;" >
                                    <label class="control-label">报名时间</label>
                                    <div class="controls">
                                        <input type="text"  id="ActivityLinkSignup_signup_start_time" value="<?php echo $ActivityLinkSignup->signup_start_time; ?>" placeholder="开始时间" name="ActivityLinkSignup[signup_start_time]" class="m-wrap medium" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});" />
                                        <input type="text" id="ActivityLinkSignup_signup_end_time" value="<?php echo $ActivityLinkSignup->signup_end_time; ?>" placeholder="结束时间" name="ActivityLinkSignup[signup_end_time]" class="m-wrap medium" onclick="WdatePickerSet($('#ActivityLinkSignup_start_time').val())" />
                                    </div>
                                </div>

                                <div class="control-group">

                                    <label class="control-label">联系人</label>
                                    <div class="controls">

                                        <?php echo $form->textField($ActivityLinkSignup, 'contacts', array('class' => 'm-wrap medium')) ?>
                                        <?php echo $form->error($ActivityLinkSignup, 'contacts', array('class' => 'label label-danger')); ?>
                                    </div>
                                </div>
                                <div class="control-group">

                                    <label class="control-label">联系电话</label>
                                    <div class="controls">

                                        <?php echo $form->textField($ActivityLinkSignup, 'tel', array('class' => 'm-wrap medium')) ?>
                                        <?php echo $form->error($ActivityLinkSignup, 'tel', array('class' => 'label label-danger')); ?>
                                    </div>
                                </div>


                                <div class="control-group">
                                    <label class="control-label">活动地址</label>
                                    <div class="controls">

                                        <?php echo $form->textField($ActivityLinkSignup, 'address', array('class' => 'm-wrap span8')) ?>
                                        <?php echo $form->error($ActivityLinkSignup, 'address', array('class' => 'label label-danger')); ?>
                                    </div>
                                </div>


                                <div class="control-group">
                                    <label class="control-label">内容</label>
                                    <div class="controls">
                                        <?php echo $form->textArea($ActivityLinkSignup, 'content', array('class' => 'm-wrap', 'style' => 'width:800px; height:400px;')) ?>
                                       
                                    </div>
                                    
                                </div>



                                <div class="form-actions ">
<!--                                    <button type="submit" class="btn blue"><i class="icon-ok"></i> 添加活动</button>-->

                                    <button type="submit"  class="btn blue"><i class="icon-ok"></i> 添加活动</button> 
<!--                                    id="submit_add"-->
                                    <button type="button" class="btn">重填</button>
                                </div>
                                    <?php $this->endWidget(); ?>


                                <!-- END FORM-->  
                            </div>

                            <div class="tab-pane " id="portlet_tab2">
                                <?php
                                $form = $this->beginWidget(
                                        'CActiveForm', array(
                                    'id' => 'vote-form',
                                    // 'enableAjaxValidation'=>true,   
                                    'enableClientValidation' => true,
                                    'clientOptions' => array(
                                        'validateOnSubmit' => true,
                                    ),
                                    'htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal'),
                                        // 'action'=>array('/admin'),
                                        ));
                                ?>	
                                <input type="hidden" id="Activity_type_id" name="Activity[type_id]" value="102" class="m-wrap small" />
                                
                                   <div class="control-group">
                                        <label class="control-label">是否热点</label>
                                        <div class="controls">
                                            <?php
                                            echo $form->radioButtonList($Activity, 'is_hot', array(1 => '是', 2 => '否'), array(
                                                'separator' => '&nbsp&nbsp&nbsp&nbsp&nbsp',
                                                'labelOptions' => array('class' => 'labelForRadio'),
                                                'style' => 'margin-left:0',
                                            ));
                                            ?>
                                        </div>
                                    </div>
                                
                                
                                
                                <?php if(!Yii::app()->user->Alumni_id):?>
                                    <div class="control-group">
                                            <label class="control-label">地区学院</label>
                                            <div class="controls">
                                                <?php echo  CHtml::dropDownList('Activity[alumni_id]','',CHtml::listData(Alumni::model()->findAllByAttributes(array('status'=>1,'is_del'=>2)),'id', 'rename'));?>
                                            </div>
                                   </div>
  
                                    <?php elseif(!Yii::app()->user->parent_id):?>    
                                     
                                    <div class="control-group">
                                            <label class="control-label">地区学院</label>
                                            <div class="controls">
                                                <?php echo  CHtml::dropDownList('Activity[alumni_id]','',CHtml::listData(Alumni::model()->findAll(
                                                        "parent_id=:parent_id and status=:status and is_del=:is_del or "
                                                        . "id=:id and status=:status and is_del=:is_del",
                                                        array(
                                                                'parent_id'=>Yii::app()->user->Alumni_id,
                                                                 'id'=>Yii::app()->user->Alumni_id,
                                                                 'is_del'=>2,
                                                                 'status'=>1 
                                                            )
                                                    ),'id','rename'));?>
                                            </div>
                                    </div>
                                <?php else:?>       
                                 <input type="hidden" id="Activity_alumni_id" name="Activity[alumni_id]" value="<?php echo Yii::app()->user->Alumni_id; ?>">
                                <?php endif;?>

                                 
                                 
                                <div class="control-group">
                                    <label class="control-label">活动类型</label>
                                    <div class="controls">
                                          <?php echo $form->dropDownList($Activity,'cat_id',Type::model()->getCategoryList(), array(
                                                                    'empty' => '请选择',
                                                                    'style' => 'width:95px',
                                                                        )); ?>
                                            <?php echo $form->error($Activity,'cat_id',array('class' => 'label label-danger')); ?>
                                            
                                
                                    </div>
                                </div>
                              
                                
                               
                               
                                <div class="control-group" >
                                    <label class="control-label">标题</label>
                                    <div class="controls">

                                    <?php echo $form->textField($Activity, 'title', array('class' => 'm-wrap large', 'placeholder' => "标题")) ?>
                                    <?php echo $form->error($Activity, 'title', array('class' => 'label label-danger')); ?>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">投票结束时间</label>
                                    <div class="controls">

                                    <?php echo $form->textField($Activity, 'start_time', array('id' => 'Activity_start_time_vote', 'class' => 'm-wrap medium', 'placeholder' => "开始时间", 'onclick' => "WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'});")) ?>

                                        <?php echo $form->error($Activity, 'end_time', array('class' => 'label label-danger')); ?> 
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">展示结束时间</label>
                                    <div class="controls">

                                    <?php echo $form->textField($Activity, 'end_time', array('class' => 'm-wrap medium', 'placeholder' => "结束时间", 'onclick' => "WdatePickerSet($('#Activity_start_time_vote').val())")) ?>
                                    <?php echo $form->error($Activity, 'end_time', array('class' => 'label label-danger')); ?> 
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">活动背景图片</label>
                                    <div class="controls">
                                        <div class="fileupload fileupload-new" data-provides="fileupload">
   
                                            <img id="file_upload_ws_vote" src="" width="150" height="85" />
                                            <input type="hidden" name='Activity[banner_url]' id="Activety_banner_url_vote">
                                            <input type="button"  id="Activity-btn-upload"  onclick="uploadImag('Activety_banner_url_vote','file_upload_ws_vote')" value='点击上传' />      
                                            <span> 请上传尺寸为700*450的图!</span>
                                        </div> 
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">活动背景缩略图片</label>
                                    <div class="controls">
                                        <div class="fileupload fileupload-new" data-provides="fileupload">
                                            <img id="file_upload_ws_min_vote" src="" width="50" height="50" />
                                            <input type="hidden" name='Activity[min_banner_url]' id="Activety_min_banner_url_vote">
                                            <input type="button" onclick="uploadImag('Activety_min_banner_url_vote','file_upload_ws_min_vote')" value='点击上传' />      
											<span> 请上传尺寸为100*100的图!</span>
										</div> 
                                    </div>
                                </div>

                                <div class="control-group col-md-offset-10">
                                    <div class="controls">
                                        <a class="btn red" data-toggle="modal" href="#add_vote">添加投票问题</a>
                                    </div>
                                </div>


<!--                            <input type="text" class="m-wrap small" id="input_option"><button class="addoption" id="add_option">增加选项单选</button>-->
                                <div class="portlet box yellow">
                                    <div class="portlet-title">
                                        <div class="caption"><i class="icon-coffee"></i>投票问题</div>
                                        <div class="tools">
                                            <a href="javascript:;" class="remove"></a>
                                        </div>
                                    </div>
                                    <div class="portlet-body">
                                        <table class="table table-bordered table-hover">
                                            <thead>
                                                <tr>
                                                    <th>问题</th>
                                                    <th>选项</th>
                                                    <th>操作</th>
                                                </tr>
                                            </thead>
                                            <tbody id="tbody_vote">

                                            </tbody>
                                        </table>
                                    </div>
                                </div>


                                <div class="form-actions">
                                    <button type="submit" id="submit_vote" class="btn blue"><i class="icon-ok"></i> 添加活动</button> 

                                    <button type="reset" class="btn" >重填</button>
                                </div>

                                <?php $this->endWidget(); ?>	

                            </div>


                        </div>
                    </div>
                </div>
            </div>
            <!-- END SAMPLE FORM PORTLET-->
        </div>
    </div>



</div>




<div id="add_vote" class="modal hide fade" tabindex="-1" data-width="560">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
        <h3>发起投票</h3>
    </div>
    <div class="modal-body">
        <div class="row-fluid">
            <div class="span6">
                <input type="text" placeholder="请填写问题" id="question" class="span12 m-wrap">

                <label class="radio">
                    <input type="radio" id="ActivityLinkVoteQ_type_id_tmp"   checked="checked" value="31" />单选
                </label>
                <div class="controls" id="answer_input_div"> 

                    <input type="text" id="answer1" placeholder="请填写答案"  name="ActivityLinkVoteA[answer][1]" class="span12 m-wrap">
                    <input type="text" id="answer2" placeholder="请填写答案"  name="ActivityLinkVoteA[answer][2]" class="span12 m-wrap">

                    <a class="blue small" id="a_add_vote" onclick="add_vote(this)">[+添加选项]</a>
                    <a class="blue small" id="a_add_vote" onclick="del_vote(this)">[-删除选项]</a>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button small" id="add_vote_ok"  class="btn blue">保存</button>
        <button type="button small" data-dismiss="modal"  onclick="colse('#add_vote')" class="btn">退出</button>
    </div>
</div>




<div class="modal fade in" id="myModal_crop_url" tabindex="-1" style="width:auto; margin: -10px 0 0 -350px; max-width:800px;display:none; " role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
               <div class="modal-dialog">
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">图片剪裁</h4>
                  </div>
                   <div class="modal-body" style="max-height:400px; ">
                       <div class="row-fluid">
                           <div class="span6">
                                <div id="jiancai_a_url_remove">
                                    <img  id="jiancai_a_url" >
                                </div>
                            </div>
                                <input type="hidden" id="x_url" name="x_url" />
                                <input type="hidden" id="y_url" name="y_url" />
                                <input type="hidden" id="w_url" name="w_url" />
                                <input type="hidden" id="h_url" name="h_url" />
                                <input type="hidden" id="input_img_url_url" name="input_img_url_url" />
                                <input type="hidden" id="img_type" name="img_type" />
                      </div>
                        
                    </div>
                    <div class="modal-footer">
                      <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                      <button type="button" class="btn btn-primary" onclick="img_sub_url()">保存</button>
                    </div>
                </div>
              </div>
            </div>






<script type="text/javascript">

    function colse(divid) {
        //var a=$('#table-user-prepaid_c0_0').val();
        $(divid).modal('hide');
    }

//    $('#submit_vote').click(function(){
//        alert(12111);
//      // return false; 
//    });

    $('#ActivityLinkSignup_is_need_signup_0').click(function() {
        if ($(this).val() == 1) {
            $("#signuptime").attr("style", "display:bolck");

        }
    });

    $('#ActivityLinkSignup_is_need_signup_1').click(function() {

        if ($(this).val() == 2) {
            $("#signuptime").attr("style", "display:none");

        }
    });

    //签到
    $('#ActivityLinkSignup_is_need_checkin_0').click(function() {

        if ($(this).val() == 1) {
            $("#checkintime").attr("style", "display:bolck");

        }
    });

    $('#ActivityLinkSignup_is_need_checkin_1').click(function() {

        if ($(this).val() == 2) {
            $("#checkintime").attr("style", "display:none");

        }
    });


    var a_i = 3;//答案数组下标
    var a_j = 3;////答案id
    var a_q = 0//提交问题数组下标
    var a_a = 1;//提交答案 数组下标
    var isNum = a_q;
    function add_vote(obj) {
        console.log(obj);
        console.log('add_vote' + a_j);
        var htmloptions = '';
        htmloptions += '<input type="text" id="answer' + a_j + '" placeholder="请填写答案" name="ActivityLink[answer][' + a_i + ']" class="span12 m-wrap">';
        $("#answer_input_div input[type='text']:last").after(htmloptions);

        a_j = a_j + 1;
        a_i = a_i + 1;

        console.log('add_vote' + a_j);
    }

    function del_vote(obj) {

        console.log('del_vote' + a_j);
        if (a_j > 2 && a_i > 2) {
            $("#answer_input_div input[type='text']:last").remove();
            a_j = a_j - 1;
            a_i = a_i - 1;
        }
        console.log('del_vote' + a_j);
    }


    $('#add_vote_ok').click(function(e) {

        a_q = a_q + 1;
        var htmlanswer = '';
        $("#answer_input_div input").each(function() {
            htmlanswer += '' + a_a + '.<input type="text" style="width:70px;" name="ActivityLinkVoteA[a_content][' + a_q + '][' + a_a + ']" value="' + $(this).val() + '" />  ';
            a_a = a_a + 1;
        });
        a_a = 1;

        var qhtml = $("#question").val();
        var q_type_id = $("#ActivityLinkVoteQ_type_id_tmp").val();
        var htmloptions = '';
        htmloptions += '<tr><td><span id=q>' + a_q + '</span><input type="text"  name="ActivityLinkVoteQ[q_content][' + a_q + ']" value="' + qhtml + '"></td><td id=a>' + htmlanswer + '</td><td><a  onclick="deleteAddCurrentRow(this);">删除问题</a><input type="hidden"  name ="ActivityLinkVoteQ[type_id]" value="' + q_type_id + '" ></td></tr>';
        //a_q =a_q+1;
        $('#tbody_vote').append(htmloptions);
        $("#question").val('');

    });



    function deleteAddCurrentRow(obj) {

        if (a_q > 1) {

            a_q = a_q - 1;
            console.log("a_q:" + a_q);
            var tr = obj.parentNode.parentNode;
            var tbody = tr.parentNode;
            tbody.removeChild(tr);

            var tmpnum;
            // console.log( $('#tbody_vote').find("tr"));
            $(tbody).each(function(i, item) {
                $.each(item.rows, function(k, v) {  //tr
                    $(v).find("span").text((k + 1));
                    $(v).find("span").next().attr('name', 'ActivityLinkVoteQ[q_content][' + (k + 1) + ']'); //问题
                    tmpnum = 1;
                    $.each($(v).find("#a"), function(kk, vv) {
                        $.each($(vv).find("input"), function(kkk, vvv) {
                            $(vvv).attr('name', 'ActivityLinkVoteA[a_content][' + (k + 1) + '][' + tmpnum + ']');
                            tmpnum = tmpnum + 1;
                        });
                    });

                });
            });
//            var V_D=$('#ActivityLinkVoteQ_del').val();
//            $('#ActivityLinkVoteQ_del').val(id+','+V_D);

        } else {
            alert("无法删除至少保留一个问题！");

        }

    }


    function WdatePickerSet(val) {
        WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss', minDate: val});
    }
    
    
    
   //裁剪为完成
   //店铺图片上传
    function img_sub_url()
    {
        var x = $('#x_url').val();
        var y = $('#y_url').val();
        var w = $('#w_url').val();
        var h = $('#h_url').val();
        var input_img_url = $('#input_img_url_url').val();
        //var input_img_id  = $('#input_img_id_url').val();
        var img_type = $('#img_type').val();
        //var hidden_update_info_url_img = $('#hidden_update_info_url_img_jian').val();
        if(x=='')
        {
            alert('请选择剪裁的区域');
            return false;
        }else
        {
            $.post(
                    '/xyhadm/activity/uploads',
                    {
                      'x':x,
                      'y':y,
                      'w':w,
                      'h':h,
                      'input_img_url':input_img_url,
                     // 'input_img_id':input_img_id,
                      'img_type':img_type
                      //'hidden_update_info_url_img':hidden_update_info_url_img
                    },
                    function(data){
                        
                        if(data){
                            alert('保存成功');
                            $('#myModal_crop_url').modal('hide');
                            $('#'+img_type).removeAttr('src');
                            $('#'+img_type).attr('src',data);
                           // $('#activity_img_cj').attr('style','display:bolck');
                             //parent.location.reload();
                        }
                        else if(data==3)
                        {
                            alert('系统繁忙请稍候在试');
                             $('#myModal_crop_url').modal('hide');
                        }
                         else if(data==4)
                        {
                            alert('图片格式不支持!');
                             $('#myModal_crop_url').modal('hide');
                        }
                                   
                    }
                    );
        }        
    }



   function updateCoords_url(c)
  {
    $('#x_url').val(c.x);
    $('#y_url').val(c.y);
    $('#w_url').val(c.w);
    $('#h_url').val(c.h);
  }

  
 
 function jiancai_url(thumb)
    {
	
        $('.jcrop-holder').remove(); 
        jcrop_api = $.Jcrop("#jiancai_a_url");
        jcrop_api.destroy();
        
        if(thumb == 'file_upload_ws' || thumb =='file_upload_ws_vote'){
                $('#jiancai_a_url').Jcrop({
                    aspectRatio: 750/445,
                    onChange: updateCoords_url
                  
                 
                  }); 
        }
            
        if(thumb == 'file_upload_ws_min' || thumb =='file_upload_ws_min_vote'){
                $('#jiancai_a_url').Jcrop({
                    aspectRatio: 1,
                    onChange: updateCoords_url
                   
            
                  }); 
        }
    
        
  } 
    
  
       

</script>

